#include "gd32f10x.h"
#include "systick.h"
#include <stdio.h>
#include "main.h"
#include "pwm.h"

/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/

int main(void)
{
    uint16_t duty = 0;
    systick_config();
    timer2_pwm_init(120 - 1, 100 - 1, 50);
    while(1)
    {
        for(duty = 0;duty < 100;duty++)
        {
            timer2_pwm_duty_set(duty);
            delay_1ms(20);
        }
        for(duty = 100;duty > 0 ;duty--)
        {
            timer2_pwm_duty_set(duty);
            delay_1ms(20);
        }
    }
}

/* retarget the C library printf function to the USART */
int fputc(int ch, FILE *f)
{
    return ch;
}
